import plotly.graph_objects as go
import numpy as np

# 生成 x 和 y 的数据点
t = np.linspace(-2 * np.pi, 2 * np.pi, 100)
x = t
y = t
z1 = np.sin(x)  # z1 = sin(x)
z2 = np.sin(y)  # z2 = sin(y)

# 创建 3D 曲线
fig = go.Figure()

# 绘制 (x, y, sin(x)) 曲线
fig.add_trace(go.Scatter3d(
    x=x,
    y=y,
    z=z1,
    mode='lines',
    name='z1 = sin(x)',
    line=dict(color='blue', width=4)
))

# 绘制 (x, y, sin(y)) 曲线
fig.add_trace(go.Scatter3d(
    x=x,
    y=y,
    z=z2,
    mode='lines',
    name='z2 = sin(y)',
    line=dict(color='red', width=4)
))

# 更新布局
fig.update_layout(
    title='3D 曲线: z = (sin(x), sin(y))',
    scene=dict(
        xaxis_title='x',
        yaxis_title='y',
        zaxis_title='z'
    ),
    margin=dict(l=0, r=0, b=0, t=30)
)

fig.show()